
package com.googlecode.yonggemovie.widgets.player;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.peer.ComponentPeer;

import javax.swing.JPanel;


public class VideoPanel extends JPanel{

	private static final long serialVersionUID = -2163411901502167841L;
	
	private PlayerPanel playerPanel;
	private Canvas canvas;//Canvas 组件表示屏幕上一个空白矩形区域，应用程序可以在该区域内绘图，或者可以从该区域捕获用户的输入事件。 
	public VideoPanel(PlayerPanel playerPanel){
		this.playerPanel = playerPanel;
		setBackground(new Color(3,3,3));
		setLayout(new VideoLayout(playerPanel));
		canvas=new Canvas();
		add(canvas);
		canvas.setName("canvas");
		canvas.setBackground(new Color(3,3,3));
	}

	//获取组件的window handle
	@SuppressWarnings("deprecation")
	public long getWid(){
		long wid=-1;
		try {
			Class<?> cl = Class.forName("sun.awt.windows.WComponentPeer");
			java.lang.reflect.Field f = cl.getDeclaredField("hwnd");
			f.setAccessible(true);
			ComponentPeer peer = canvas.getPeer();
			wid = f.getLong(peer);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return wid;
	}
}


